import { RECORD_STATUS } from '@/enum/common';
import {
  DNYMIC_LIKE_STATUS,
  DYNAMIC_TYPE,
  FOLLOW_STATUS,
} from '@/enum/dynamic';
import { Column, Entity, OneToOne, PrimaryGeneratedColumn } from 'typeorm';
import { BaseEntity } from './base.entity';
import { User } from './user.entity';

@Entity('dynamic')
export class Dynamic extends BaseEntity {
  @PrimaryGeneratedColumn({
    type: 'int',
    name: 'id',
    comment: '主键，自增',
  })
  id: number;

  @Column({
    type: 'int',
    name: 'user_id',
    comment: '发布人id',
  })
  userId: number;

  @Column({
    type: 'int',
    name: 'type',
    comment: `动态类型`,
  })
  type: DYNAMIC_TYPE;

  @Column({
    type: 'text',
    name: 'content',
    comment: '动态内容',
  })
  content: string;

  @Column({
    type: 'text',
    name: 'images',
    comment: '动态图片（每个图片之间以,分割存储）',
  })
  images: string;

  @Column({
    type: 'int',
    name: 'views',
    comment: '浏览量',
    default: 0,
  })
  views: number;

  @Column({
    type: 'int',
    name: 'status',
    comment: '动态状态',
    default: RECORD_STATUS.SHOW,
  })
  status: RECORD_STATUS;

  @OneToOne(() => User, (userInfo) => userInfo.id)
  userInfo?: User;

  /**
   * 点赞数
   */
  love: number;

  /**
   * 点赞状态
   */
  loveStatus: DNYMIC_LIKE_STATUS;

  /**
   * 评论数
   */
  comment: number;

  /**
   * 用户关注状态
   */
  followStatus: FOLLOW_STATUS;
}
